public class TestArrs {
    public static void main(String[] args) {
        /*
         - 数组声明必须明确元素的类型
         - 每个元素类型须相同
         - 数组初始化需要明确元素个数
         */

        //数组声明   类型 数组名[]   类型[] 数组名        
        int y[];  y = new int[3];//先声明 后初始化
        int []x = {1,2,3};//声明并初始化

        for (int i = 0; i < x.length; i++) {//遍历   x.length返回数组元素个数
            System.out.println(x[i]);//访问数组元素，[下表索引] 0 ~ n-1
        }

        for (int i : y) {//增强for
            System.out.println(y[i]);
        }
        //======================================================================
        int a = 3, b = a;
        System.out.println(a + " | " + b);
        a=4;
        System.out.println(a + " | " + b);
        //-----------------------修改变量a，变量b的值是否受影响？
        int arr1[] = {1,2,3};
        int arr2[] = arr1;
        for (int i = 0; i < arr1.length; i++) {
            System.out.println("arr1:" + arr1[i] + " | " + "arr2:" + arr2[i]);
        }
        //------------------------修改arr1第二个元素的值，打印什么？
        arr1[1] = 13;
        for (int i = 0; i < arr1.length; i++) {
            System.out.println("arr1:" + arr1[i] + " | " + "arr2:" + arr2[i]);
        }
        //======================================================================
        //多维数组 声明定义
        int darr[][] = new int[2][3];
         
        int darr2 [ ][ ]; 
        darr2 = new int[2][2];
        /*
        int arr[][] = new int[3][ ]; 
        int arr[][] = new int[ ][4];//错误
        
        int arr[][] = {{0,1},{0,1,2},{0,1,2,3}};
        */
    }
}
